package db

import (
	"com.wen/model"
	"fmt"
)

func GetCommentList(articleId int64, pageNum, pageSize int) (commentList []*model.Comment, err error) {

	if pageNum < 0 || pageSize < 0 {
		err = fmt.Errorf("invalid parameter, page_num:%d, page_size:%d", pageNum, pageSize)
		return
	}

	sqlstr := `select 
							id, content, username, create_time
						from 
							comment 
						where 
							article_id = ? and 
							status = 1
						order by create_time desc
						limit ?, ?`

	err = DB.Select(&commentList, sqlstr, articleId, pageNum, pageSize)
	return
}
